﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.Serialization;
using System.ServiceModel;
using System.ServiceModel.Web;
using System.Text;
using System.Threading;

namespace SampleService
{
    public class SampleService : ISampleService
    {
        public string LongOperation(string name)
        {
            Sleep();

            if (name == "kill")
                throw new InvalidOperationException("Error as requested by caller.");

            return string.Format("You entered: {0}", name);
        }

        private static void Sleep()
        {
            Thread.Sleep(2000);
        }

        private static int _customerId;
        private static int _addressId;
        public int AddCustomer(string name)
        {
            if (name == "kill")
                throw new InvalidOperationException("Error as requested by caller.");

            Sleep();

            return _customerId++;
        }

        public int AddAddress(int customerId, string address)
        {
            if (address == "kill")
                throw new InvalidOperationException("Error as requested by caller.");

            Sleep();

            return _addressId++;
        }
    }
}
